package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.R;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author zhmwi
 * @Date 2021/7/9
 * @Dersciption
 */
@Api("医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    @ApiOperation("带条件带分页的查询医院列表")
    @RequestMapping("/queryByPageAndCondition/{page}/{limit}")
    public R queryByPageAndCondition(@PathVariable("page") Integer page,
                                     @PathVariable("limit") Integer limit,
                                     HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pages = hospitalService.queryByPageAndCondition(page,limit,hospitalQueryVo);
        return R.ok().data("pages",pages);
    }
    //更新上线状态
    @ApiOperation("更新上线状态")
    @GetMapping("updateStatus/{hosId}/{status}")
    public R updateStatus(@PathVariable("hosId") String hosId,
                          @PathVariable("status") Integer status){
        hospitalService.updateStatus(hosId,status);
        return R.ok();
    }
    //查询医院详情
    @ApiOperation("查询医院详情")
    @GetMapping("getHospitalInfo/{id}")
    public R getHospitalInfo(@PathVariable("id") String id){
        Map<String,Object> map = hospitalService.getHospitalInfo(id);
        return R.ok().data(map);
    }
}
